import 'package:flutter/material.dart';
import 'package:get/get.dart';

import '../decrypt/view.dart';
import '../encrypt/view.dart';
import '../genkey/view.dart';
import '../sign/view.dart';
import 'logic.dart';

class MainNavigationPage extends StatefulWidget {
  @override
  _MainNavigationPageState createState() => _MainNavigationPageState();
}

class _MainNavigationPageState extends State<MainNavigationPage> {
  late final NavController navController;

  @override
  void initState() {
    super.initState();
    navController = Get.find<NavController>();
  }


  @override
  Widget build(BuildContext context) {
    return Scaffold(
        appBar: AppBar(
          title: Text('加密算法'),
          centerTitle: true, // 强制标题居中
          elevation: 4, // 添加阴影效果[7](@ref)
        ),
        // body: IndexedStack(
        //   index: _currentIndex,
        //   children: _pages,
        // ),
        body: PageView(
          controller: navController.pageController,
          physics: NeverScrollableScrollPhysics(parent: const BouncingScrollPhysics()),
          children: [GeneratePage(), EncryptPage(), DecryptPage(), SignPage()],
        ),
        bottomNavigationBar: Obx(
          () => BottomNavigationBar(
            currentIndex: navController.currentIndex.value,
            onTap: navController.changeTab,
            items: const [
              BottomNavigationBarItem(
                icon: Icon(Icons.vpn_key),
                label: '生成',
              ),
              BottomNavigationBarItem(
                icon: Icon(Icons.lock),
                label: '加密',
              ),
              BottomNavigationBarItem(
                icon: Icon(Icons.lock_open),
                label: '解密',
              ),
              BottomNavigationBarItem(
                icon: Icon(Icons.person),
                label: '签名',
              ),
            ],
            selectedItemColor: Colors.blue[800], // 选中颜色加深
            unselectedItemColor: Colors.grey,
          ),
        ));
  }
}
